import http from "@/api/config/http";
import { IQuery, IResponse, ITableResponse } from "@/interface/IAxios";
import { LabelValue } from "@arco-design/web-vue/es/tree-select/interface";

export const listDictData = (query: IQuery) => {
  return http.request<ITableResponse<DictData>>({
    url: `/system/dict/data/list`,
    method: "get",
    params: query
  });
};

// 生成其他的接口
export const getDictData = (id: string) => {
  return http.request({
    url: `/system/dict/data/${id}`,
    method: "get"
  });
};

export const addDictData = (data: any) => {
  return http.request({
    url: `/system/dict/data`,
    method: "post",
    data
  });
};

export const updateDictData = (data: any) => {
  return http.request({
    url: `/system/dict/data`,
    method: "put",
    data
  });
};

export const delDictData = (id: string) => {
  return http.request({
    url: `/system/dict/data/${id}`,
    method: "delete"
  });
};
export const getDict = (dictType: string): Promise<IResponse<LabelValue[]>> => {
  return http.request({
    url: `system/dict/data/kv`,
    params: {
      dictType
    }
  });
};
